﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    var from = $.request("from");
    var form = $.request("fromDialog");
    var organizeId = $.request("organizeId");
    var isContansChildOrg = $.request("isContansChildOrg");
    var keyValue = $.request("keyValue");
    var isExpand = $.request("isExpand");
    var callbackType = $.request("callbackType");
    var single = $.request("single");
    var isShowEmpty = $.request("isShowEmpty");
    $(function () {
        initControl();
        $('#btn_search').click(function () {
            initControl();
        });
    })
    //回车事件
    $('#txt_keyword').keydownEnterEvent(function () {
        $('#btn_search').trigger('click');
    })
    function initControl() {
        var urladdr = "/SystemManage/User/GetSysUserSelectorTreeQ?from=" + from + "&isContansChildOrg=" + isContansChildOrg + "&keyValue=" + keyValue + "&isExpand=" + isExpand + "&callbackType=" + callbackType + "&single=" + single + "&isShowEmpty=" + isShowEmpty + "&orgId=" + organizeId;
        var keyword = $("#txt_keyword").val();
        if (!!keyword) {
            urladdr += "&keyword=" + keyword;
        }
        $("#userStaffTree").treeview({
            height: 290,
            slimscroll: false,
            showcheck: true,
            url: urladdr,
        });
    }

    function AcceptClick(callBack) {
        var treeSeleData;
        if (callbackType == 'json') {
            treeSeleData = $("#userStaffTree").getCheckedNodeObjArray();
            if (single == 'true' && treeSeleData.length != 1) {
                $.modalAlert('最多选中一条', 'warning');
                return;
            }
        }
        else {
            treeSeleData = $("#userStaffTree").getCheckedValues();  //Values对应的是UserId
            if (single == 'true' && treeSeleData.length != 1) {
                $.modalAlert('最多选中一条', 'warning');
                return;
            }
            treeSeleData = String(treeSeleData);
        }
        $.each(treeSeleData, function (index, item) {
            treeSeleData[index].Ex3 = organizeId;
        });
        callBack(treeSeleData);
        $.modalClose();
    }
</script>
<form id="form1">
    <div class="topPanel">
        <div class="search">
            <table>
                <tr>
                    <td>
                        <div class="input-group">
                            <input id="txt_keyword" type="text" class="form-control" placeholder="姓名/工号" style="width: 180px;">
                            <span class="input-group-btn">
                                <button id="btn_search" type="button" class="btn btn-primary"><i class="fa fa-search"></i></button>
                            </span>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div class="widget-body">
        <div id="userStaffTree"></div>
    </div>
</form>


